#include <bits/stdc++.h>
using namespace std;

using ll = long long;
ll dp[510][510];
ll n, m, k;

int main()
{
	ll ret = 0;
	cin >> n >> m >> k;
	for (int i = 1; i <= n; i++)
	{
		for (int j = 1; j <= m; j++)
		{
			int tmp;
			cin >> tmp;
			dp[i][j] = dp[i][j - 1] + dp[i - 1][j] - dp[i - 1][j - 1] + tmp;
		}
	}
	for (int i = 1; i <= n; i++)
	{
		for (int j = i; j <= n; j++)
		{
			for (int l = 1, r = 1; r <= m; r++)
			{
				while (l <= r && dp[j][r] - dp[j][l - 1] - dp[i - 1][r] + dp[i - 1][l - 1] > k) l++;
				if (l <= r) ret += r - l + 1;
			}
		}
	}
	cout << ret << endl;
	return 0;
}
